import request from "@/utils/request";
import { PRODUCE } from "@/config/baseUrl.js";

// 查询生产工单列表
export function getProduceList(data) {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/list`,
    method: "post",
    data,
  });
}

// 查询接班详情
export function getProduceDetails(data) {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/getTakeoverInfo`,
    method: "post",
    data,
  });
}

// 查询接班详情(生产准备)
export function getTakeoverInfoById(produceLogId) {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/getTakeoverInfoById`,
    method: "get",
    params: { produceLogId },
  });
}

// 查询登陆用户负责的产线和班组
export function getUserChargedLineAndGroup() {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/getUserChargedLineAndGroup`,
    method: "get",
  });
}

// 查询生产工单列表
export function getOrderList(data) {
  return request({
    url: `${PRODUCE}/order/erpOrder/list`,
    method: "post",
    data,
  });
}

// 根据工单刷新工位人员安排
export function getStationUserInfos(data) {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/refreshStationUserInfos`,
    method: "post",
    data,
  });
}

// 单独修改工位人员安排
export function saveStationUserInfos(data) {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/updateStationUserInfos`,
    method: "post",
    data,
  });
}

// 保存接班详情
export function saveProduce(data) {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/saveTakeoverInfo`,
    method: "post",
    data,
  });
}

// 确认接班并开始生产
export function submitProduce(data) {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/takeoverAndStartProduce`,
    method: "post",
    data,
  });
}

// 生产准备
export function prepareProduce(data) {
  return request({
    url: `${PRODUCE}/handover/groupProduceLog/prepareToProduce`,
    method: "post",
    data,
  });
}
